package com.freesky.biz.abchina.controller;

import com.freesky.biz.abchina.domain.TCreditRecord;
import com.freesky.biz.abchina.domain.TCreditRecordNew;
import com.freesky.biz.abchina.domain.TLoanRecord;
import com.freesky.biz.abchina.service.ICreditRecordService;
import com.freesky.biz.abchina.service.ILoanRecordService;
import com.freesky.common.annotation.Log;
import com.freesky.common.core.controller.BaseController;
import com.freesky.common.core.domain.AjaxResult;
import com.freesky.common.core.page.TableDataInfo;
import com.freesky.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@RestController
@RequestMapping("/abchina/credit/record")
public class CreditRecordController extends BaseController {

    @Autowired
    private ICreditRecordService creditRecordService;

    /**
     * 信用卡权益列表
     */
    @PreAuthorize("@ss.hasPermi('abchina:creditrecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(TCreditRecord creditRecord) {
        startPage();
        List<TCreditRecord> list = creditRecordService.findList(creditRecord);
        return getDataTable(list);
    }

    @Log(title = "信用卡权益", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('abchina:creditrecord:export')")
    @GetMapping("/export")
    public AjaxResult export(TCreditRecord creditRecord,
                             HttpServletResponse response) {
        return creditRecordService.exportFile(creditRecord);
    }

    @PreAuthorize("@ss.hasPermi('abchina:creditrecord:list')")
    @GetMapping("/listNew")
    public TableDataInfo listNew(TCreditRecordNew creditRecord) {
        startPage();
        List<TCreditRecordNew> list = creditRecordService.findNewList(creditRecord);
        return getDataTable(list);
    }

    @Log(title = "信用卡权益", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('abchina:creditrecord:export')")
    @GetMapping("/exportNew")
    public AjaxResult exportNew(TCreditRecordNew creditRecord,
                             HttpServletResponse response) {
        return creditRecordService.exportNewFile(creditRecord);
    }

}
